using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
 
public partial class JobSeekers_myaccount : System.Web.UI.Page
{
    string connectionString = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        connectionString =
             WebConfigurationManager.ConnectionStrings[
               "RecruitVietnam"].ConnectionString;
        
        if(Session.Contents["rcuserid"]==null)
        {
            Response.Redirect("login.aspx");
        }
        lblAccount.Text = Session.Contents[
        "rccompanyname"]+"'s account";
         
        if(!IsPostBack)
        {
            ShowAccount();
        }
    }
    void ShowAccount()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);        
        cls.CommandText = "select  * from " +
        " vwRCAccount where RecruiterID='"
        + Session["rcuserid"] + "'";
        DataRow dataRow =
        cls.GetDataRow();
        if (dataRow != null)
        {
            hyperLinkTitle.Text = dataRow[2].ToString();
            if(dataRow[2].ToString() != "")
            hyperLinkTitle.Text += "<br>(" + 
            dataRow[3].ToString() + ")";
            hyperLinkTitle.NavigateUrl = "profile.aspx";
             
           if(dataRow[3].ToString() == "True")
           {
                imgRequiredField.Visible = true;
                hylRquiredField.Visible = true;
           }
           
           if(dataRow[4].ToString() == "True")           
                Literal8.Text = "Employers";
           else             
                Literal8.Text = "Staffing Firms";
           if (dataRow[5].ToString() == "True")
                Literal9.Text = "Yes";
            else
                Literal9.Text = "No";
            if (dataRow[13].ToString() == "True")
            {
                Literal10.Text = "Yes";
                literalWarning.Text = "";
                }
            else
            {
                Literal10.Text = "No";
                literalWarning.Text = 
                "<img border=0 src='/icons/warning.gif'>"+
                "You can not use RCV Jobs and Viewing" +
                " services, because this account is"+
                " not approved by management team.";
            }
           Literal11.Text = dataRow[6].ToString();
           Literal12.Text = dataRow[7].ToString();
           Literal1.Text = dataRow[8].ToString();
           Literal2.Text = dataRow[9].ToString();
           Literal3.Text = dataRow[10].ToString();
           Literal4.Text = dataRow[11].ToString();
           Literal5.Text = dataRow[12].ToString();
           if(Literal5.Text == "0") 
            lbtResetStatistics.Visible = false;
           Literal6.Text = dataRow[14].ToString();
        }
    }
    protected void lbtResetStatistics_Click(object sender, EventArgs e)
    {
        if(ResetStatistics())
            ShowAccount();
    }
    bool ResetStatistics()
    {
        SqlServerProvider cls = new 
        SqlServerProvider(connectionString);
        cls.CommandText = "SPResetRCView";
        cls.CommandType = CommandType.StoredProcedure;
        cls.ParameterCollection = new
        string[1] { "@RecruiterID" };
        cls.ValueCollection = new
        string[1]{Convert.ToString(
            Session.Contents["rcuserid"])};         
      
        return (cls.ExecuteNonQuery()>0);
    }
}
